package com.coder.bike.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.coder.bike.entity.BikeMaker;
import com.coder.bike.mapper.BikeMakerMapper;
import com.coder.bike.service.IBikeMakerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 沈诩宸
 * @since 2025-04-22
 */
@Service
public class BikeMakerServiceImpl extends ServiceImpl<BikeMakerMapper, BikeMaker> implements IBikeMakerService {

    @Override
    public Page<BikeMaker> search(int start, int size, BikeMaker autoMaker) {
        QueryWrapper<BikeMaker> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByAsc("id")
                .like(StrUtil.isNotEmpty(autoMaker.getName()), "name",
                        autoMaker.getName());
        Page<BikeMaker> page= new Page<>(start, size);
        this.page(page, queryWrapper);
        return page;
    }
}
